//
//  Help_DetailViewController.m
//  MZJ
//
//  Created by XDD on 16/6/27.
//  Copyright © 2016年 XDD. All rights reserved.
//

#import "Help_DetailViewController.h"

@interface Help_DetailViewController ()<UIWebViewDelegate,UIScrollViewDelegate,ModelDelegate>

@property (nonatomic, strong) UIWebView *helpNews_webView;
@property (nonatomic, strong) ModelViewController *modelViewController;
@property (nonatomic, strong) JSNetWorkingModel *model;


@end

@implementation Help_DetailViewController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = YES;
    self.tabBarController.tabBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.topBar.backgroundColor = [UIColor colorWithRed:253/255.0 green:179/255.0 blue:10/255.0 alpha:1];
    self.titleLabel.text = @"详情";
    self.view.backgroundColor = [UIColor colorWithRed:245/255.0 green:245/255.0 blue:245/255.0 alpha:1];
    [self.backButton setTitle:@"" forState:UIControlStateNormal];
    
    _helpNews_webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 55, kWidth, kHeight - 55)];
    _helpNews_webView.delegate = self;
    _helpNews_webView.scrollView.delegate = self;
    [self.view addSubview:_helpNews_webView];
    
    if (!_modelViewController) {
        _modelViewController = [[ModelViewController alloc]init];
        [_modelViewController modelUrl_Http_Request:news_info_model fileName:@"News_infoModel.txt" webview:_helpNews_webView];
    }
    
    if (!_model) {
        _model = [[JSNetWorkingModel alloc]init];
    }

}

//点击返回键
- (void)clickedBackButton:(UIButton *)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
    self.tabBarController.tabBar.hidden = YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView  {
    
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[DataModel object].helps_News_Str forKey:@"arid"];
    __weak typeof (self)weakSelf = self;
    [_model setBlockWithReturnBlock:^(id returnValue) {
        
        //        NSLog(@"%@",returnValue);
//        NSString* aStr= [[NSString alloc] initWithData:returnValue encoding:NSUTF8StringEncoding];
//        
//        NSString *sddsd = [NSString stringWithFormat:@"Home.news_detail.V.create(%@)",aStr];
        
//        [weakSelf.helpNews_webView stringByEvaluatingJavaScriptFromString:sddsd];
        [weakSelf.modelViewController JS_datarequestinitWebView:@"Home.news_detail.V.create" andData:returnValue andwebView:weakSelf.helpNews_webView];
        
    } WithErrorBlock:^(id errorCode) {
        
    }];
    
    [_model JS_HomeGetHelp_News_info:dic];
    [GiFHUD dismiss];

}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    
}

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [GiFHUD show];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
